﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:system="clr-namespace:System;assembly=mscorlib" 
																				xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Custom="http://metro.mahapps.com/winfx/xaml/controls" xmlns:Custom1="http://metro.mahapps.com/winfx/xaml/shared" mc:Ignorable="d">
	
	<BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" />

	<Color x:Key="WindowBackgroundColor">#efeff2</Color>
	<Color x:Key="HighlightColor">#fdfdfd</Color>
	<Color x:Key="BlueColor">#007acc</Color>
	<Color x:Key="ForegroundColor">#1e1e1e</Color>
	<Color x:Key="MenuItemBackgrounColor">#e7e8ec</Color>
	

	<SolidColorBrush x:Key="WindowBackgroundColorBrush" Color="{StaticResource WindowBackgroundColor}"/>
	<SolidColorBrush x:Key="HighlightColorBrush" Color="{StaticResource HighlightColor}"/>
	<SolidColorBrush x:Key="BlueColorBrush" Color="{StaticResource BlueColor}"/>
	<SolidColorBrush x:Key="ForegroundColorBrush" Color="{StaticResource ForegroundColor}"/>
	<SolidColorBrush x:Key="MenuItemBackgroundColorBrush" Color="{StaticResource MenuItemBackgrounColor}"/>

	<ControlTemplate  x:Key="MenuItemTemplate" TargetType="{x:Type MenuItem}">
		<Border x:Name="templateRoot"
			Background="{StaticResource WindowBackgroundColorBrush}"
			BorderBrush="{TemplateBinding BorderBrush}"
			BorderThickness="{TemplateBinding BorderThickness}"
			SnapsToDevicePixels="True">
			<Grid VerticalAlignment="Center">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
				</Grid.ColumnDefinitions>
				<ContentPresenter x:Name="Icon"
					Width="20"
					Height="20"
					Margin="3"
					HorizontalAlignment="Center"
					VerticalAlignment="Center"
					Content="{TemplateBinding Icon}"
					ContentSource="Icon"
					SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
				<Path x:Name="GlyphPanel"
					Margin="3"
					VerticalAlignment="Center"
					Data="F1M10,1.2L4.7,9.1 4.5,9.1 0,5.2 1.3,3.5 4.3,6.1 8.3,0 10,1.2z"
					Fill="{TemplateBinding Foreground}"
					FlowDirection="LeftToRight"
					Visibility="Collapsed" />
				<ContentPresenter Grid.Column="1"
					Margin="0,0,5,0"
					HorizontalAlignment="Center"
					VerticalAlignment="Center"
					Content="{TemplateBinding Header}"
					ContentSource="Header"
					ContentStringFormat="{TemplateBinding HeaderStringFormat}"
					ContentTemplate="{TemplateBinding HeaderTemplate}"
					RecognizesAccessKey="True"
					SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
				<Popup x:Name="PART_Popup"
					AllowsTransparency="True"
					Focusable="False"
					IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
					Placement="Bottom"
					PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
					<Border x:Name="SubMenuBorder"
						Background="#FFF0F0F0"
						BorderBrush="#FF999999"
						BorderThickness="1"
						Padding="2">
						<ScrollViewer x:Name="SubMenuScrollViewer" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
							<Grid x:Name="ContainerGrid" RenderOptions.ClearTypeHint="Enabled">
								<Canvas Width="0"
									Height="0"
									HorizontalAlignment="Left"
									VerticalAlignment="Top">
									<Rectangle x:Name="OpaqueRect"
										Width="{Binding ActualWidth, ElementName=SubMenuBorder}"
										Height="{Binding ActualHeight, ElementName=SubMenuBorder}"
										Fill="{Binding Background, ElementName=SubMenuBorder}" />
								</Canvas>
								<Rectangle Width="1"
									Margin="21,2,0,2"
									HorizontalAlignment="Left"
									Fill="#FFD7D7D7" />
								<ItemsPresenter x:Name="ItemsPresenter"
									Grid.IsSharedSizeScope="True"
									KeyboardNavigation.DirectionalNavigation="Cycle"
									KeyboardNavigation.TabNavigation="Cycle"
									SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
							</Grid>
						</ScrollViewer>
					</Border>
				</Popup>
			</Grid>
		</Border>
		<ControlTemplate.Triggers>
			<Trigger Property="IsSuspendingPopupAnimation" Value="True">
				<Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
			</Trigger>
			<Trigger Property="Icon" Value="{x:Null}">
				<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
			</Trigger>
			<Trigger Property="IsChecked" Value="True">
				<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
				<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
			</Trigger>
			<Trigger Property="IsHighlighted" Value="True">
				<Setter TargetName="templateRoot" Property="Background" Value="#3D26A0DA" />
				<Setter TargetName="templateRoot" Property="BorderBrush" Value="#FF26A0DA" />
			</Trigger>
			<Trigger Property="IsEnabled" Value="False">
				<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="#FF707070" />
				<Setter TargetName="GlyphPanel" Property="Fill" Value="#FF707070" />
				<Setter TargetName="templateRoot" Property="Opacity" Value="0.2" />
			</Trigger>
			<Trigger SourceName="SubMenuScrollViewer" Property="CanContentScroll" Value="False">
				<Setter TargetName="OpaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=SubMenuScrollViewer}" />
				<Setter TargetName="OpaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=SubMenuScrollViewer}" />
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>

	<Style x:Key="WindowButtonStyle" TargetType="{x:Type Button}">
		<Setter Property="Foreground" Value="{DynamicResource ForegroundColorBrush}" />
		<Setter Property="Background" Value="Transparent" />
		<Setter Property="HorizontalContentAlignment" Value="Center" />
		<Setter Property="VerticalContentAlignment" Value="Center" />
		<Setter Property="Padding" Value="1" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					<Grid Background="{TemplateBinding Background}">
						<ContentPresenter x:Name="contentPresenter"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                          Margin="{TemplateBinding Padding}"
                          RecognizesAccessKey="True" />
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="Background" Value="{StaticResource HighlightColorBrush}" />
							<Setter Property="Foreground" Value="{StaticResource BlueColorBrush}" />
						</Trigger>
						<Trigger Property="IsPressed" Value="True">
							<Setter Property="Background" Value="{DynamicResource BlueColorBrush}" />
							<Setter Property="Foreground" Value="{StaticResource HighlightColorBrush}" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter TargetName="contentPresenter" Property="Opacity" Value=".5" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="ModernWindowStyle" TargetType="Window">
		<Setter Property="Foreground" Value="{DynamicResource ForegroundColorBrush}" />
		<Setter Property="Background" Value="{DynamicResource WindowBackgroundColorBrush}"/>
		<Setter Property="ResizeMode" Value="CanResizeWithGrip" />
		<Setter Property="UseLayoutRounding" Value="True" />
		<Setter Property="TextOptions.TextFormattingMode" Value="Display" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="Window">
					<Border x:Name="WindowBorder" Margin="{Binding Source={x:Static SystemParameters.WindowNonClientFrameThickness}}" Background="{StaticResource WindowBackgroundColorBrush}">
						<Grid>
							<Border BorderThickness="1">
								<AdornerDecorator>
									<Grid x:Name="LayoutRoot">
										<Grid.RowDefinitions>
											<RowDefinition Height="25" />
											<RowDefinition Height="*" />
											<RowDefinition Height="15" />
										</Grid.RowDefinitions>
										<ContentPresenter Grid.Row="1" Grid.RowSpan="2" Margin="7"/>
										<Rectangle x:Name="HeaderBackground" Height="25" Fill="{DynamicResource WindowBackgroundColorBrush}" VerticalAlignment="Top" Grid.Row="0"/>
										<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" WindowChrome.IsHitTestVisibleInChrome="True" Grid.Row="0">
											<Button Command="{Binding Source={x:Static SystemCommands.MinimizeWindowCommand}}" ToolTip="minimize" Style="{StaticResource WindowButtonStyle}">
												<Button.Content>
													<Grid Width="30" Height="25" RenderTransform="1,0,0,1,0,1">
														<Path Data="M0,6 L8,6 Z" Width="8" Height="7" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                        Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="2"  />
													</Grid>
												</Button.Content>
											</Button>
											<Grid Margin="1,0,1,0">
												<Button x:Name="Restore" Command="{Binding Source={x:Static SystemCommands.RestoreWindowCommand}}" ToolTip="restore" Visibility="Collapsed" Style="{StaticResource WindowButtonStyle}">
													<Button.Content>
														<Grid Width="30" Height="25" UseLayoutRounding="True" RenderTransform="1,0,0,1,.5,.5">
															<Path Data="M2,0 L8,0 L8,6 M0,3 L6,3 M0,2 L6,2 L6,8 L0,8 Z" Width="8" Height="8" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                            Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="1"  />
														</Grid>
													</Button.Content>
												</Button>
												<Button x:Name="Maximize" Command="{Binding Source={x:Static SystemCommands.MaximizeWindowCommand}}" ToolTip="maximize" Style="{StaticResource WindowButtonStyle}">
													<Button.Content>
														<Grid Width="31" Height="25">
															<Path Data="M0,1 L9,1 L9,8 L0,8 Z" Width="9" Height="8" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                            Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="2"  />
														</Grid>
													</Button.Content>
												</Button>
											</Grid>
											<Button Command="{Binding Source={x:Static SystemCommands.CloseWindowCommand}}" ToolTip="close"  Style="{StaticResource WindowButtonStyle}">
												<Button.Content>
													<Grid Width="30" Height="25" RenderTransform="1,0,0,1,0,1">
														<Path Data="M0,0 L8,7 M8,0 L0,7 Z" Width="8" Height="7" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                        Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="1.5"  />
													</Grid>
												</Button.Content>
											</Button>
										</StackPanel>
										<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" >
											<Image Source="{TemplateBinding Icon}"/>
											<TextBlock x:Name="WindowTitleTextBlock" Grid.Row="0" Text="{TemplateBinding Title}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center"  Margin="8 -1 0 0"  FontSize="16"  Foreground="{TemplateBinding Foreground}"/>
										</StackPanel>
										<Grid Grid.Row="2">
											<Path x:Name="ResizeGrip" Visibility="Collapsed" Width="12" Height="12" Margin="1" HorizontalAlignment="Right"
                                        Stroke="{StaticResource BlueColorBrush}" StrokeThickness="1" Stretch="None" Data="F1 M1,10 L3,10 M5,10 L7,10 M9,10 L11,10 M2,9 L2,11 M6,9 L6,11 M10,9 L10,11 M5,6 L7,6 M9,6 L11,6 M6,5 L6,7 M10,5 L10,7 M9,2 L11,2 M10,1 L10,3" />
										</Grid>
									</Grid>
								</AdornerDecorator>
							</Border>
							<Border BorderBrush="LightGray" BorderThickness="1" Visibility="{Binding IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource bool2VisibilityConverter}}" />
						</Grid>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="WindowState" Value="Maximized">
							<Setter TargetName="Maximize" Property="Visibility" Value="Collapsed" />
							<Setter TargetName="Restore" Property="Visibility" Value="Visible" />
							<Setter TargetName="LayoutRoot" Property="Margin" Value="7" />
						</Trigger>
						<Trigger Property="WindowState" Value="Normal">
							<Setter TargetName="Maximize" Property="Visibility" Value="Visible" />
							<Setter TargetName="Restore" Property="Visibility" Value="Collapsed" />
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="ResizeMode" Value="CanResizeWithGrip" />
								<Condition Property="WindowState" Value="Normal" />
							</MultiTrigger.Conditions>
							<Setter TargetName="ResizeGrip" Property="Visibility" Value="Visible" />
						</MultiTrigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="WindowChrome.WindowChrome">
			<Setter.Value>
				<WindowChrome CornerRadius="0" GlassFrameThickness="1" UseAeroCaptionButtons="False" />
			</Setter.Value>
		</Setter>
	</Style>
	<SolidColorBrush x:Key="Menu.Static.Background" Color="#FFF0F0F0"/>
	<Style x:Key="MenuStyle1" TargetType="{x:Type Menu}">
		<Setter Property="Background" Value="{StaticResource WindowBackgroundColorBrush}"/>
		<Setter Property="FontFamily" Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}"/>
		<Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
		<Setter Property="FontStyle" Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}"/>
		<Setter Property="FontWeight" Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Menu}">
					<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
						<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>